package com.onenine.app.utils;


import com.onenine.app.view.nineimage.NineGridImageView;

import java.util.Random;

/**
 * 多图随机器
 */
public class MultiImageRandom {

    private static final Random RANDOM = new Random();
    private static final int[] SPAN_TYPE1 = {NineGridImageView.BOTTOMCOLSPAN, NineGridImageView.TOPCOLSPAN
            , NineGridImageView.LEFTROWSPAN};
    private static final int[] SPAN_TYPE2 = {NineGridImageView.NOSPAN, NineGridImageView.BOTTOMCOLSPAN
            , NineGridImageView.TOPCOLSPAN, NineGridImageView.LEFTROWSPAN};

    private MultiImageRandom() {
    }

    /**
     * 随机生成多图SpanType类型
     *
     * @param count
     * @return
     */
    public static int getRandomSpanType(int count) {
        if (count > 9) {
            return NineGridImageView.NOSPAN;
        }
        if (count <= 2) {
            return NineGridImageView.NOSPAN;
        }
        if (count == 3) {
            return SPAN_TYPE1[RANDOM.nextInt(count)];
        }
        if (count == 4) {
            return SPAN_TYPE2[RANDOM.nextInt(count)];
        }
        return SPAN_TYPE1[RANDOM.nextInt(3)];
    }


}
